#include "RingQueue.hpp"
void* Producer(void* arg)
{
  RingQueue<int>* rq = (RingQueue<int>*)arg;
  while (true){
   // sleep(1);
    int data = rand() % 100 + 1;
    rq->push(data);
    //std::cout << "Producer: " << data << std::endl;
    printf("Producer: %d\n",data);
  }
}
void* Consumer(void* arg)
{
  RingQueue<int>* rq = (RingQueue<int>*)arg;
  while (true){
    sleep(1);
    int data = 0;
    rq->pop(data);
    //std::cout << "Consumer: " << data << std::endl;
    printf("Consumer: %d\n",data);
  }
}

int main()
{
  srand((unsigned int)time(nullptr));
  pthread_t producer, consumer;
  RingQueue<int>* rq = new RingQueue<int>;
  pthread_create(&producer, nullptr, Producer, rq);
  pthread_create(&consumer, nullptr, Consumer, rq);
  pthread_join(producer, nullptr);
  pthread_join(consumer, nullptr);
  delete rq;
  return 0;
}
